package com.lkd.controller;

import com.lkd.dto.SkuPageDto;
import com.lkd.entity.Sku;
import com.lkd.result.PageBean;
import com.lkd.result.Result;
import com.lkd.service.SkuService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;


@Slf4j
@RestController
@RequestMapping("/api/vm-service/sku/")
public class SkuController {
    @Autowired
    private SkuService skuService;


    //新增商品
    @PostMapping
    public Result save(@RequestBody Sku sku){
        Boolean result=skuService.save(sku);
        return Result.success(result);
    }

    //商品搜索
    @GetMapping("/search")
    public Result getPage(SkuPageDto skuPageDto){
        PageBean pageBean = skuService.getPage(skuPageDto);
        return Result.success(pageBean);
    }

    //修改商品
    @PutMapping
    public Result update(@RequestBody Sku sku){
        Boolean result=skuService.update(sku);
        return Result.success(result);
    }

}
